/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

/**
 * This class is the class that determines based on user input the number of vertical alnes
 * @author Luke
 */
public class UCNum_VertLanes extends UCMenuOption {

    /**
     * This is the run method that is invoked through the menu when the user selects
     * the appropriate number to get to this menu option
     * @return The returned value is the value the user has chosen to enter for this menu item
     * or conversely the default value because the user has not selected one,
     */
    
    @Override
    public Integer run() {
        System.out.println(get_MenuOption()); // System asks for number of vertical lanes
        String userInput = theInput.nextLine(); //User enters a value for the number of lanes
        int the_Check = checkInput(userInput); //System checks the input for validity
        if (the_Check == 0) {
            System.out.println("The input given was not a number, try again please."); //System informs user of bad input
            run(); //System asks user for number of vertical lanes (again)
        } else if (the_Check == 1) {
            int int_userInput = Integer.parseInt(userInput);
            if (int_userInput > 0 && int_userInput < 5) { //System checks the input for validity
                return (int_userInput); //System accepts the users input for the number of vertical lanes
            } else {
                System.out.println("The input given was not between 1 and 5, try again please."); //System informs user of bad input
                run(); //System asks user for number of vertical lanes (again)
            }

        }
        return (2); //System uses the default value for the number of vertical lanes
    }
}
